"""

@Time: 2021/9/13 9:48
@Author:
@File: __init__.py.py
"""

from pydantic import BaseModel, Field
from typing import List
from models.po.mysql_po import Volunteer as VolOrmSchema

class VolItem(BaseModel):
    """一个志愿项"""
    serial: int = Field(title='志愿序号')
    school_id: str = Field(title='院校 id')
    major: str = Field(title='专业名')

class VolList(BaseModel):
    id: str = Field(title='学生的考生号')
    vol_items: List[VolItem] = Field(title='志愿列表')

class Province(BaseModel):
    id: int = Field(title='省份 id')
    name: str = Field(title='省份名')


class VolQueryCond(BaseModel):
    province: str = Field(default=None, title='省份名')
    is_985: int = Field(default=None, title='是否为985')
    is_211: int = Field(default=None, title='是否为211')
    low_score: int = Field(default=None, title='分数区间的较低')
    high_score: int = Field(default=None, title='')
    major: str = Field(default=None, title='专业名')

class Volunteer(BaseModel):
    id: int
    name: str
    university_code: str
    province: str
    city: str
    is_985: int
    is_211: int
    major: str
    lowest_score: int

    @staticmethod
    def from_mysql_schema(v: VolOrmSchema):
        return Volunteer(id=v.id,
                         name=v.name,
                         university_code=v.university_code,
                         province=v.province,
                         city=v.city,
                         is_985=v.is_985,
                         is_211=v.is_211,
                         major=v.professional_name,
                         lowest_score=v.lowest_score)